[C#] LINQ Group By


In some scenarios, we would like to select each first one row
of the group which we group by personId.

The following code block is a simple example.

var memberList =
    memberSourceData.GroupBy(item => item.personId)
        .Select(chunck => chunck
            .OrderByDescending(c => c.Id)
            .First())
        .ToList();
#C#






你可能感興趣的文章

# JavaScript Immutable ( 不可變 ) 概念

# JavaScript Immutable ( 不可變 ) 概念

API

API

Chrome 83 DevTools 新功能:切換 location 與 locales

Chrome 83 DevTools 新功能:切換 location 與 locales






留言討論